<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>L2LB: utils.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Gerado por Doxygen 1.5.6 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Página&nbsp;principal</span></a></li>
      <li><a href="annotated.html"><span>Estruturas&nbsp;de&nbsp;dados</span></a></li>
      <li class="current"><a href="files.html"><span>Ficheiros</span></a></li>
    </ul>
  </div>
<h1>utils.h</h1><a href="utils_8h.html">Ir para a documentação deste ficheiro.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00006"></a>00006 <span class="preprocessor">#ifndef UTILS_H_</span>
<a name="l00007"></a>00007 <span class="preprocessor"></span><span class="preprocessor">#define UTILS_H_</span>
<a name="l00008"></a>00008 <span class="preprocessor"></span>
<a name="l00014"></a><a class="code" href="utils_8h.html#b0f950c72d35e5d0cffbf735b7123284">00014</a> <span class="keywordtype">void</span> <a class="code" href="utils_8h.html#b0f950c72d35e5d0cffbf735b7123284" title="Imprime um endereço MAC no log do kernel.">printk_mac_addr</a>(<span class="keyword">const</span> u8 *<a class="code" href="structksock__thread__t.html#b05c8fa2261a2415f74822c88667289b">addr</a>) 
<a name="l00015"></a>00015 {
<a name="l00016"></a>00016         <span class="keywordflow">if</span>(!addr) {
<a name="l00017"></a>00017                 printk( KERN_ALERT MODULE_NAME <span class="stringliteral">": MAC Address null!\n"</span> );
<a name="l00018"></a>00018         }
<a name="l00019"></a>00019         <span class="keywordflow">else</span> <span class="keywordflow">if</span>(!is_valid_ether_addr(addr)) {
<a name="l00020"></a>00020                 printk( KERN_ALERT MODULE_NAME <span class="stringliteral">": MAC Address invalid!\n"</span> );
<a name="l00021"></a>00021         }
<a name="l00022"></a>00022         <span class="keywordflow">else</span> {
<a name="l00023"></a>00023                 printk( KERN_ALERT MODULE_NAME <span class="stringliteral">": %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n"</span>, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] );
<a name="l00024"></a>00024         }
<a name="l00025"></a>00025 }
<a name="l00026"></a>00026 
<a name="l00033"></a><a class="code" href="utils_8h.html#7a719668dc1cee29bc80d85386ad478e">00033</a> <span class="keywordtype">void</span> <a class="code" href="utils_8h.html#7a719668dc1cee29bc80d85386ad478e" title="Parse um endereço IPv4.">parse_ipv4_addr</a>(<span class="keywordtype">char</span> *c, u32 *<a class="code" href="structksock__thread__t.html#b05c8fa2261a2415f74822c88667289b">addr</a>)
<a name="l00034"></a>00034 {
<a name="l00035"></a>00035         <span class="keywordtype">int</span> a[4];
<a name="l00036"></a>00036         sscanf(c, <span class="stringliteral">"%d.%d.%d.%d"</span>, &amp;a[0], &amp;a[1], &amp;a[2], &amp;a[3]);
<a name="l00037"></a>00037         *addr = (a[3] &lt;&lt; 24) + (a[2] &lt;&lt; 16) + (a[1] &lt;&lt; 8) + a[0];
<a name="l00038"></a>00038 }
<a name="l00039"></a>00039 
<a name="l00040"></a>00040 <span class="preprocessor">#endif </span><span class="comment">/*UTILS_H_*/</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Gerado em Wed Sep 10 23:05:55 2008 para L2LB por&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
</body>
</html>
